package com.ruoyi.land.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.land.domain.MfLandlord;
import com.ruoyi.land.service.IMfLandlordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 房东信息Controller
 * 
 * @author yuanrui
 * @date 2025-07-22
 */
@RestController
@RequestMapping("/land")
public class MfLandlordController extends BaseController
{
    @Autowired
    private IMfLandlordService mfLandlordService;

    /**
     * 查询房东信息列表
     */
    @RequiresPermissions("land:land:list")
    @GetMapping("/list")
    public TableDataInfo list(MfLandlord mfLandlord)
    {
        startPage();
        List<MfLandlord> list = mfLandlordService.selectMfLandlordList(mfLandlord);
        return getDataTable(list);
    }

    /**
     * 导出房东信息列表
     */
    @RequiresPermissions("land:land:export")
    @Log(title = "房东信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MfLandlord mfLandlord)
    {
        List<MfLandlord> list = mfLandlordService.selectMfLandlordList(mfLandlord);
        ExcelUtil<MfLandlord> util = new ExcelUtil<MfLandlord>(MfLandlord.class);
        util.exportExcel(response, list, "房东信息数据");
    }

    /**
     * 获取房东信息详细信息
     */
    @RequiresPermissions("land:land:query")
    @GetMapping(value = "/{landlordId}")
    public AjaxResult getInfo(@PathVariable("landlordId") Long landlordId)
    {
        return success(mfLandlordService.selectMfLandlordByLandlordId(landlordId));
    }

    /**
     * 新增房东信息
     */
    @RequiresPermissions("land:land:add")
    @Log(title = "房东信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MfLandlord mfLandlord)
    {
        return toAjax(mfLandlordService.insertMfLandlord(mfLandlord));
    }

    /**
     * 修改房东信息
     */
    @RequiresPermissions("land:land:edit")
    @Log(title = "房东信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MfLandlord mfLandlord)
    {
        return toAjax(mfLandlordService.updateMfLandlord(mfLandlord));
    }

    /**
     * 删除房东信息
     */
    @RequiresPermissions("land:land:remove")
    @Log(title = "房东信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{landlordIds}")
    public AjaxResult remove(@PathVariable Long[] landlordIds)
    {
        return toAjax(mfLandlordService.deleteMfLandlordByLandlordIds(landlordIds));
    }

}
